<template>
  <el-card>
    <template #header>
      <div class="clearfix">
        <span>合约列表</span>
        <el-button @click="router.push('/home/partner/contracts/add')" style="float: right; padding: 3px 0" type="text">添加</el-button>
      </div>
    </template>
    <el-table :data="contractsList" style="width: 100%">
      <el-table-column prop="contractId" label="合约编号" ></el-table-column>
      <el-table-column prop="contractName" label="合约名称" ></el-table-column>
      <el-table-column prop="franchisee" label="加盟方" ></el-table-column>
      <el-table-column prop="signDate" label="签订日期"></el-table-column>
      <el-table-column prop="amount" label="金额" width="100">
        <template #default="scope">
          ¥{{ scope.row.amount }}
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态" width="100"></el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="150">
        <template #default="scope">
          {{ scope.row.createTime.substring(0, 10) }}
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { fetchContractsList } from "../../../../api/ContractsApi.ts";
import router from "../../../../router";

const contractsList = ref([]);

const getContractsList = async () => {
  const res = await fetchContractsList();
  if (res.code === 200) {
    contractsList.value = res.data
  }
};


getContractsList();

</script>

<style scoped>
.el-card {
  margin-top: 20px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 0 #ffffff;
  outline: 0;
}
</style>
